<?php
 $typel = $this->type;
 if($this->type == 30){
        function_exists(date_default_timezone_set);//在这他总是返回1,这函数是判断这里面的字符是不是一个定义了的函数名 
          date_default_timezone_set('PRC');
          $timeinfo = time();
          $datassc = $this->getRows("select * from {$this->prename}auto_0 order by id desc limit 2");
          $msg = array();
          if($datassc[0] && $datassc[1]){
            foreach ($datassc as $key => $value) {
               $msg[$key]['actionNo'] = $value['actionNo'];
               $msg[$key]['actionTime'] = $value['actionTime'];
            }
              $feng = strtotime($msg[0]['actionTime'])-180;
              $fengtime = date("Y/m/d H:i:s",$feng);
              $kaitime = $msg[0]['actionTime'];

          }elseif($datassc[0] && !isset($datassc[1])){
              $msg[1]['actionNo'] = $datassc[0]['actionNo'];
              $msg[0]['actionNo'] = $datassc[0]['actionNo']+1;
              $feng = strtotime($datassc[0]['actionTime'])-180;
              $fengtime = date("Y/m/d H:i:s",$feng);
              $kaitime = $datassc[0]['actionTime'];
               
          }else{
              $msg[1]['actionNo'] = "";
              $msg[0]['actionNo'] = "";
              $kais = $timeinfo+1;
              $kaitime = date("Y/m/d H:i:s",$kais);
        }
 }
   $lastNo=$this->getGameLastNo($this->type);
    $kjHao=$this->getValue("select data from {$this->prename}data where type={$this->type} and number='{$lastNo['actionNo']}'");
    if($kjHao) $kjHao=explode(',', $kjHao);
    $actionNo=$this->getGameNo($this->type);
    $types=$this->getTypes();
    $kjdTime=$types[$this->type]['data_ftime'];
    $diffTime=strtotime($actionNo['actionTime'])-$this->time-$kjdTime;
    $kjDiffTime=strtotime($lastNo['actionTime'])-$this->time;
?>
<?php
   if($this->type == 30){
       ?>
         <div class="lot-tip">
          <div class="lot-time">
            <p style="color:"><span id="last_period"><?= $msg[1]['actionNo'] ?></span>期</p>
            <div class="wait-lot" style="margin-top: 5px;">
                <?php
      if($datassc[1]['ok']== 1){
        ?>
      <div class="ball" id="ball">
        <div id="balls">
          <span style="font-size: 15px;color:#FE962F;"><?php echo str_replace(',', ' ', $datassc[1]['ball']);?></span>
           </div>
          </div>
      <?php
      }else{
        ?>
        <div class="kais" style="font-size: 15px;color:#FE962F">等待开奖</div>
        <?php
      }
      ?></div>
          </div>
          <div class="dat-time">
            <p>距<span id="current_period" class="qishu"><?php echo $msg[0]['actionNo'];?></span>期<span id="current_period_status">截止</span></p>
            <div class="time-late">
              <span id="time_hh1">0</span>
              <span id="time_hh2">0</span>
              <span class="time-kong"></span>
              <span id="time_mm1">0</span>
              <span id="time_mm2">0</span>
              <span class="time-kong"></span>
              <span id="time_ss1">0</span>
              <span id="time_ss2">0</span>
            </div>
          </div>
        </div>
       <?php
   }else{
       ?>
  <div class="lot-tip">
    <div class="lot-time">
      <p><span id="last_period"><?=($lastNo['actionNo']?$lastNo['actionNo']:"----------")?></span>期</p>
     <!--  <div class="wait-lot"> -->
       <?php
       if($this->type == 20){
        ?>
         <div class="wait-lot" style="padding: 10px;margin:auto;margin-top: -10px;width:110px; word-wrap: break-word;word-break:break-all;line-height: 15px;">
        <i class="time-ico" style="display:none;"></i><span id="last_open" style="font-size: 15px; color: #FE962F">
        <?php
       }else{
        ?>
        <div class="wait-lot" style="margin-top: 5px;">
        <i class="time-ico" style="display:none;"></i><span id="last_open" style="font-size: 15px; color: #FE962F">
        <?php
       }
       ?>
      <?=$kjHao?join(" ",$kjHao):"等待开奖"?>
      </span></div>
    </div>
    <div class="dat-time">
      <p>距<span id="current_period"><?=($actionNo['actionNo']?$actionNo['actionNo']:"----------")?></span>期<span id="current_period_status">截止</span></p>
      <div class="time-late" id="pre-kanjiang">
        <span id="time_h1">0</span>
        <span id="time_h2">0</span>
        <span class="time-kong"></span>
        <span id="time_m1">0</span>
        <span id="time_m2">0</span>
        <span class="time-kong"></span>
        <span id="time_s1">0</span>
        <span id="time_s2">0</span>
      </div>
    </div>
  </div>

       <?php
   }
?>




    <div class="bd" id="kaijiang" type="<?=$this->type?>" ctype="<?=$types[$this->type]['type']?>"></div>
     
       <?php if($types[$this->type]['type']==4) { //快乐十分?>
       <td width="420" class="game_top_aright"> 
      <div class="kj-bottom"><span class="tit"><span class='gamename'><?=$types[$this->type]['title']?></span>&nbsp;&nbsp;第 <span class="last_issues"><b><?=$lastNo['actionNo']?></span></b> 期  总共:<b style="color:#FF0000"><?=$types[$this->type]['num']?></b>&nbsp;期  <span id="kjsay">开奖倒计时：<em class="kjtips">00:00</em></span></span><img id="voice" class="voice-on"  title="声音开启，点击关闭" onclick="voiceKJ()"><span id="lockgame"></span><div class="clear"></div></div>
          <div class="grid_code_ssc wjkjData" style="margin-top:15px; margin-left:25px;">
              <p class="hide"><img src="/images/common/kjts.png" /></p>
              <ul class="kj-hao" ctype="g1" cnum="20">
                <li id="span_lot_0" class="gr_s gr_s020"> <?=$kjHao[0]?> </li>
                <li id="span_lot_1" class="gr_s gr_s020"> <?=$kjHao[1]?> </li>
                <li id="span_lot_2" class="gr_s gr_s020"> <?=$kjHao[2]?> </li>
                <li id="span_lot_3" class="gr_s gr_s020"> <?=$kjHao[3]?> </li>
                <li id="span_lot_4" class="gr_s gr_s020"> <?=$kjHao[4]?> </li>
                <li id="span_lot_5" class="gr_s gr_s020"> <?=$kjHao[5]?> </li>
                <li id="span_lot_6" class="gr_s gr_s020"> <?=$kjHao[6]?> </li>
                <li id="span_lot_7" class="gr_s gr_s020"> <?=$kjHao[7]?> </li>

              </ul>
              <div class="clear"></div>
          </div>   
    </td>
      <td class="game_top_period" width='260' >
      <div style='padding:3px 5px' id='historylot'>
        <?php  $this->display('index/inc_data_history.php'); ?>
        </div>
    </td>
    
     <?php }else if($types[$this->type]['type']==10) { //六合彩?>
       <td class="game_top_aright"> 
      <div class="kj-bottom"><span class="tit">&nbsp;&nbsp;第 <span class="last_issues"><?=$lastNo['actionNo']?></span> 期  <span id="kjsay">开奖倒计时：<em class="kjtips">00:00</em></span></span><img id="voice" class="voice-on"  title="" onclick="voiceKJ()"><span id="lockgame"></span><div class="clear"></div></div>
          <div class="grid_code_tl wjkjData" >
               <p style="display:none"><img src="/images/common/kjts.png" /></p>
              <ul class="kj-hao" ctype="g1" cnum="49" style="margin-left:60px;padding-top:20px;">
                    <li id="span_lot_0" class="gr_s gr_s020"> <?=$kjHao[0]?> </li>
                    <li id="span_lot_1" class="gr_s gr_s020"> <?=$kjHao[1]?> </li>
                    <li id="span_lot_2" class="gr_s gr_s020"> <?=$kjHao[2]?> </li>
                    <li id="span_lot_3" class="gr_s gr_s020"> <?=$kjHao[3]?> </li>
                    <li id="span_lot_4" class="gr_s gr_s020"> <?=$kjHao[4]?> </li>
                    <li id="span_lot_5" class="gr_s gr_s020"> <?=$kjHao[5]?> </li>
          <li id="span_lot_5" class="gr_s gr_s020"> <?=$kjHao[6]?> </li>
              </ul>
              <div class="clear"></div>
           </div> 
    </td>
    
     <?php }else if($types[$this->type]['type']==6) { //PK10?>
       <td width="445" class="game_top_aright"> 
      <div class="kj-bottom"><span class="tit"><span class='gamename'><?=$types[$this->type]['title']?></span>&nbsp;&nbsp;第 <span class="last_issues"><b><?=$lastNo['actionNo']?></span></b> 期  总共:<b style="color:#FF0000"><?=$types[$this->type]['num']?></b>&nbsp;期  <span id="kjsay">开奖倒计时：<em class="kjtips">00:00</em></span></span><img id="voice" class="voice-on"  title="声音开启，点击关闭" onclick="voiceKJ()"><span id="lockgame"></span><div class="clear"></div></div>
          <div class="grid_code_ssc wjkjData" style="margin-top:15px;">
              <p class="hide"><img src="/images/common/kjts.png" /></p>
              <ul class="kj-hao" ctype="g1" cnum="10">
                <li id="span_lot_0" class="gr_s gr_s020"> <?=$kjHao[0]?> </li>
                <li id="span_lot_1" class="gr_s gr_s020"> <?=$kjHao[1]?> </li>
                <li id="span_lot_2" class="gr_s gr_s020"> <?=$kjHao[2]?> </li>
                <li id="span_lot_3" class="gr_s gr_s020"> <?=$kjHao[3]?> </li>
                <li id="span_lot_4" class="gr_s gr_s020"> <?=$kjHao[4]?> </li>
                <li id="span_lot_5" class="gr_s gr_s020"> <?=$kjHao[5]?> </li>
                <li id="span_lot_6" class="gr_s gr_s020"> <?=$kjHao[6]?> </li>
                <li id="span_lot_7" class="gr_s gr_s020"> <?=$kjHao[7]?> </li>
                <li id="span_lot_8" class="gr_s gr_s020"> <?=$kjHao[8]?> </li>
                <li id="span_lot_9" class="gr_s gr_s020"> <?=$kjHao[9]?> </li>
              </ul>
              <div class="clear"></div>
          </div>   
    </td>
      <!--td class="game_top_period" width='265' >
      <div style='padding:3px 5px' id='historylot'>
        <?php  $this->display('index/inc_data_history.php'); ?>
        </div>
    </td>-->
     <?php }else if($types[$this->type]['type']==9) { //快3?>
      <td width="400" class="game_top_aright"> 
      <div class="kj-bottom"><span class="tit"><span class='gamename'><?=$types[$this->type]['title']?></span>&nbsp;&nbsp;第 <span class="last_issues"><b><?=$lastNo['actionNo']?></span></b> 期  总共:<b style="color:#FF0000"><?=$types[$this->type]['num']?></b>&nbsp;期  <span id="kjsay">开奖倒计时：<em class="kjtips">00:00</em></span> </span><img id="voice" class="voice-on"  title="声音开启，点击关闭" onclick="voiceKJ()"><span id="lockgame"></span><div class="clear"></div></div>  
            <div class="grid_code_tl wjkjData" >
              <p class="hide"><img src="/images/common/kjtsk3.jpg" /></p>
              <ul class="kj-hao k3" ctype="g2"  cnum="6" style="margin-left:70px;">
                    <li id="span_lot_0" class="gr_ks gr_ks<?=intval($kjHao[0])?>"> </li>
                    <li id="span_lot_1" class="gr_ks gr_ks<?=intval($kjHao[1])?>"> </li>
                    <li id="span_lot_2" class="gr_ks gr_ks<?=intval($kjHao[2])?>"> </li>
                  </ul>
              <div class="clear"></div>
           </div>
       </td> 
     
     
      
   
      
  <?php }else{  ?>
       
         <td width="440" class="game_top_aright"> 
      <div class="kj-bottom"><span class="tit"><span class='gamename'><?=$types[$this->type]['title']?></span>&nbsp;&nbsp;第 <span class="last_issues"><b><?=$lastNo['actionNo']?></b></span> 期  总共:<b style="color:#FF0000"><?=$types[$this->type]['num']?></b>&nbsp;期  <div class="clear"></div></div>  
              <div class="grid_code_ssc wjkjData" >
                  <p class="hide"><img src="/images/common/kjts.png" /></p>
                  <ul class="kj-hao" ctype="g0"  cnum="10">
                    <li id="span_lot_0" class="gr_s gr_s<?=intval($kjHao[0])?>"> </li>
                    <li id="span_lot_1" class="gr_s gr_s<?=intval($kjHao[1])?>"> </li>
                    <li id="span_lot_2" class="gr_s gr_s<?=intval($kjHao[2])?>"> </li>
                    <li id="span_lot_3" class="gr_s gr_s<?=intval($kjHao[3])?>"> </li>
                    <li id="span_lot_4" class="gr_s gr_s<?=intval($kjHao[4])?>"> </li>
                  </ul>
                  <div class="clear"></div>
            </div>   
             
    </td>

      
       <?php }?>
        </tr>
      </table>
    </div> 
    <?php if($types[$this->type]['type']==8) {?>
  <div style="padding:3px 5px;border:1px solid #cccccc; margin-top:10px;" id="historylot" class="game_top_period">
        <?php  $this->display('index/inc_data_history.php'); ?>
    </div>
   <?php }?>
<script type="text/javascript">
$(function(){
  FastClick.attach(document.body);
  
  window.S=<?=json_encode($diffTime>0)?>;
  window.KS=<?=json_encode($kjDiffTime>0)?>;
  window.kjTime=parseInt(<?=json_encode($kjdTime)?>);
  
  if($.browser.msie){
    //window.diffTime=<?=$diffTime?>;
    setTimeout(function(){
      gameKanJiangDataC(<?=$diffTime?>);
    }, 1000);
  }else{
    setTimeout(gameKanJiangDataC, 1000, <?=$diffTime?>);
  }
  <?php if($kjDiffTime>0){ ?> 
    if($.browser.msie){
    setTimeout(function(){
      setKJWaiting(<?=$kjDiffTime?>);
    }, 1000);
    }else{
      setTimeout(setKJWaiting, 1000, <?=$kjDiffTime?>);
    }
  <?php } ?> 
  
  <?php if(!$kjHao){ ?> 
    loadKjData();
  <?php } ?> 
  
  /*头部玩法标题*/
  var tit1 = $(".game-btn .ul-li.current a").text();
  var tit2 = $(".game-btn2 .ul-li.current a").text();
  $("#play_name").text(tit1+"-"+tit2);
});

//var time = "1524446301";
var types = <?php echo json_encode($typel);?>;
if(types == 30){
var time = <?php echo json_encode($timeinfo);?>;
var NowTime = new Date();
var test = NowTime.getTime();
test = Math.floor(test/1000);
var cha = time-test;

//开奖倒计时
function GetRTime1(){

 // var fp_time = "2018-04-23 09:22:50";
    var fp_time = <?php echo json_encode(strtotime($kaitime));?>;
    var EndTime= fp_time*1000;
    var NowTime = new Date();
    var t =EndTime - (NowTime.getTime()+cha*1000);

    // var fp_time = <?php echo json_encode($kaitime);?>;
    // var EndTime= new Date(fp_time);
    // var NowTime = new Date();

    // var t =EndTime.getTime() - (NowTime.getTime()+cha*1000);
    var m=0;
    var s=0;
    var h=0;
    if(t>=0){
      h=Math.floor(t/1000/3600);
      m=Math.floor(t/1000/60%60);
      s=Math.floor(t/1000%60);
    }
       if(h<10){
          $("#time_hh1").html(0);
          $("#time_hh2").html(h.toString().split(""));
      }else{
          $("#time_hh1").html(h.toString().split("")[0]);
          $("#time_hh2").html(h.toString().split("")[1]);
      }
      if(m<10){
          $("#time_mm1").html(0);
          $("#time_mm2").html(m.toString().split(""));
      }else{
          $("#time_mm1").html(m.toString().split("")[0]);
          $("#time_mm2").html(m.toString().split("")[1]);
      }
      if(s<10){
          $("#time_ss1").html(0);
          $("#time_ss2").html(s.toString().split(""));
      }else{
          $("#time_ss1").html(s.toString().split("")[0]);
          $("#time_ss2").html(s.toString().split("")[1]);
      }
    if(m==0 && s==0 && h==0){ 
      clearInterval(window.kaijiang);
      var qishu =$(".qishu").text();
      $.post('/index.php/user/hongplay',{qishu:qishu},function(data){
          if(data == 200){ 
            window.location.reload();
          }
      });
           window.location.reload();
    }

    
}
 var kaijiang = setInterval(GetRTime1,0);
}else{
  console.log("不是六合彩");
}

  //两秒刷新一次开奖
    setInterval(function () { 
       $("#ball").load("/index.php/index/game/30 #balls");
    }, 2000);
/*    $("#qishu").click(function(){
      $("#ball").load("/index.php/index/ssc #balls");
    })*/
</script>






